﻿using Microsoft.Extensions.Logging;

namespace Unity.Logger
{
    public static class UnityLogger
    {
        private const LogLevel DefaultLogLevel = LogLevel.Debug;

        public static readonly ILoggerFactory ConsoleLoggerFactory = DefaultConsoleLoggerConfiguration();
        private static ILoggerFactory DefaultConsoleLoggerConfiguration()
        {
            return LoggerFactory.Create(logger =>
            {
                logger.SetMinimumLevel(DefaultLogLevel);
                logger.AddLoggerConsole();
            });
        }

        private static readonly string DefaultLoggerFilename = "unity.client.log";

        public static readonly ILoggerFactory FileLoggerFactory = DefaultFileLoggerConfiguration(DefaultLoggerFilename);

        private static ILoggerFactory DefaultFileLoggerConfiguration(string filename)
        {
            return LoggerFactory.Create(configuration =>
            {
                configuration.SetMinimumLevel(DefaultLogLevel);
                configuration.AddLoggerFile(filename);
            });
        }

    }
}